<?php
/**
 * 日志业务逻辑类
 * User: 苏近之
 * Date: 2019-03-23
 * Time: 21:45
 */

namespace app\common\service;

use app\common\model\Log;

class LogService
{

    /**
     * 写入日志
     * @param string $title
     * @param string $category
     * @param string $level
     * @param string|array $content
     */
    public static function write($title, $category, $level, $content)
    {
        if(is_array($content)){
            $content = json_encode($content);
        }
        $status = Log::STATUS_NORMAL;
        (new Log())->insert(compact('title', 'category', 'level', 'content', 'status'));
    }
}